package com.shanghaionstar.alarm;

import android.content.Context;
import android.content.Intent;

/**
 * 闹钟代理：
 *    通过闹钟工厂类生成闹钟，接管闹钟的事件处理
 * Created by Yonglang Hong on 2017/1/11.
 */
public class AlarmProxy {

    Alarm alarm;

    Context context;

    public AlarmProxy(Context context) {
        this.context = context;
    }

    private Alarm getAlarm(Intent intent) {
        AlarmActionType actionType = AlarmActionType.actionOf(intent.getAction());
        return getAlarm(actionType);
    }

    private Alarm getAlarm(AlarmActionType actionType){
        alarm = AlarmFactory.getInstance().create(actionType);
        return alarm;
    }

    public void alarm(AlarmActionType actionType){
        getAlarm(actionType).alarm(context);
    }

    public void cancel(AlarmActionType actionType){
        getAlarm(actionType).cancel(context);
    }

    public void showTip(Intent intent){
        getAlarm(intent).showAlarmTip(context,intent);
    }

}
